//
//  MacroDefinition.h
//  ubereasycontrol
//
//  Created by app on 15/10/19.
//  Copyright © 2015年 devpltc. All rights reserved.
//
#import <Foundation/Foundation.h>
#ifndef MacroDefinition_h
#define MacroDefinition_h
/**
 *  app当前版本
 */
#define APP_VERSION [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"]
/**
 *  偏好设置中保存的app版本
 */
#define USER_DEFAULT_VERSION [USER_DEFAULT doubleForKey:@"com.pinglianApp.version"]
/**
 *  判断是真机还是模拟器
 */
#if TARGET_OS_IPHONE
//iPhone Device
#endif

#if TARGET_IPHONE_SIMULATOR
//iPhone Simulator
#endif

//定义一个API
#define APIURL                @"http://xxxxx/"
//登陆API
#define APILogin              [APIURL stringByAppendingString:@"Login"]

#define BASE_URL @""
/**
 *  获取物理屏幕的尺寸
 */
#define SCREEN_HEIGHT   ([UIScreen mainScreen].bounds.size.height)
#define SCREEN_WIDTH    ([UIScreen mainScreen].bounds.size.width)


#define kIMAGE(ImageName)           [UIImage imageNamed:ImageName]
#define kFONT(FontSize)             [UIFont systemFontOfSize:FontSize]
#define kBOLDFONT(FontSize)         [UIFont boldSystemFontOfSize:FontSize]
#define kSEL(SELName)               @selector(SELName)
#define kPoint(x,y)                 CGPointMake(x,y)

/**
 *   判断是否是iPhone6p
 */
#define IS_IPHONE_6P ([UIScreen mainScreen].bounds.size.height > 667)
/**
 *   判断是否是iPhone6
 */
#define IS_IPHONE_6 ([UIScreen mainScreen].bounds.size.height == 667)
/**
 *   判断是否是iPhone5
 */
#define IS_IPHONE_5 ([UIScreen mainScreen].bounds.size.height == 568)

/**
 *   判断是否是iPhone4s
 */
#define IS_IPHONE_4S ([UIScreen mainScreen].bounds.size.height == 480)
/**
 *  判断是否为IOS7
 */
#define iOS8 ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0)
#define iOS7 ([[UIDevice currentDevice].systemVersion floatValue] >= 7.0)

/**
 *  通知中心
 */
#define NOTIFICATION_CENTER     [NSNotificationCenter defaultCenter]
#define LOGINSUCCESS @"loginsuccess"

/**
 *  偏好设置
 */
#define USER_DEFAULT    [NSUserDefaults standardUserDefaults]

#define kSaveUserDefaults(obj,key)  [USER_DEFAULT setObject:obj forKey:key];\
                                    [USER_DEFAULT synchronize]

#define kGetUserDefaults(key) [USER_DEFAULT objectForKey:key]

#define kRemoveUserDefaults(key) [USER_DEFAULT removeObjectForKey:key]


/**
 *  重写NSLog,Debug模式下打印日志和当前行数
 */
#if DEBUG
#define NSLog(FORMAT, ...) fprintf(stderr,"\n <line: %d> <function:%s> \n%s\n", __LINE__, __FUNCTION__,[[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
#else
#define NSLog(FORMAT, ...) nil
#endif

//----------------------系统----------------------------

//获取系统版本
#define IOS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]
#define CurrentSystemVersion [[UIDevice currentDevice] systemVersion]

//获取当前语言
#define CurrentLanguage ([[NSLocale preferredLanguages] objectAtIndex:0])
//判断是否 Retina屏、设备是否%fhone 5、是否是iPad
#define isRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)
#define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)

//----------------------颜色类---------------------------
// rgb颜色转换（16进制->10进制）
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

//带有RGBA的颜色设置
#define COLOR(R, G, B, A) [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:A]

// 获取RGB颜色
#define RGBA(r,g,b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]
#define RGB(r,g,b) RGBA(r,g,b,1.0f)

//背景色
#define BACKGROUND_COLOR [UIColor colorWithRed:242.0/255.0 green:236.0/255.0 blue:231.0/255.0 alpha:1.0]

//清除背景色
#define CLEARCOLOR [UIColor clearColor]

#pragma mark - color functions
#define RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]
#define RGBACOLOR(r,g,b,a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)]

//----------------------图片----------------------------

//读取本地图片
#define LOADIMAGE(file,ext) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle]pathForResource:file ofType:ext]]

//定义UIImage对象
#define IMAGE(A) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:A ofType:nil]]

//定义UIImage对象
#define ImageNamed(_pointer) [UIImage imageNamed:[UIUtil imageName:_pointer]]

//建议使用前两种宏定义,性能高于后者











#endif /* MacroDefinition_h */
